import {defineStore} from "pinia";
import { Ref, ref } from "vue";
import { useRouter } from "vue-router";
let useUserStore=defineStore("userStore",()=>{
    const router=useRouter();
    let token=ref(null);//用户的token
    let userId=ref(0);
    let userType:Ref<number>=ref(0);
    const logout = () => {
        token.value = null;
        userId.value = 0;
        userType.value = 0;
        router.push("/login");
    };
    let clear=()=>{
        token.value=null;
        userId.value=0;
        userType.value=0;
    }
    return{
        token,
        userId,
        userType,
        logout,
        clear
    }
},{
    persist:true
})
export default useUserStore;